Skip to main content

Upload a File Using an Expression

In Bizagi, you may upload any file to a File-type attribute without an end user's intervention using an expression, uploading the content of the file (as an Array of type sbyte).

For example, in a Loans Request Process, the Process Entity is called Request. Assume in this entity there is a File-type attribute called HistoryFile that will store a letter uploaded via Web service. l

Example Process

The Web Service returns a Bytes Array that contains the data of the file. Assume this array is saved in the variable FileData.

To upload a file using an Expression, you must type the following code:

var FileToUpload = Me.addRelation("Request.HistoryFile");
FileToUpload.setXPath("FileName", "DisplayNameOfTheFile.txt");
FileToUpload.setXPath("Data", FileData);

FileName and Data (shown in red) should NOT change. They are part of the code.

Note these parameters are components of a file-type attribute. The File Name is the display name of the file. The Data contains the information of the file.

l

Note this expression is similar to the ones used to add records to a collection. This is because file-type attributes are treated as a collection of files, for this reason you can upload many files in a single attribute.

The uploaded file will look like this:

l

If you need to know how to obtain the Path of a Bizagi uploaded file, please refer to Obtain the Path of a file